/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.converter;

import br.com.deployment.entities.City;
import br.com.deployment.entities.Organ;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author luciano
 */
@FacesConverter(value = "organConverter")
public class OrganConverter implements Converter{
       
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Organ organ = new Organ();
        if(! value.equals("null"))
          organ.setId((Long.valueOf(value)));
        return organ ;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        Organ organ = (Organ) value;
        return  "" + organ.getId();
    }
}
